package cn.shadow.concurrent;

import cn.shadow.utils.ObjectHolder;

import java.util.concurrent.CountDownLatch;

public class Task implements Runnable {
    private DisruptorExecutor executor;
    private ObjectHolder<Thread> holder;
    private CountDownLatch countDownLatch;

    public Task(DisruptorExecutor executor, ObjectHolder<Thread> holder, CountDownLatch countDownLatch) {
        this.executor = executor;
        this.holder = holder;
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        this.holder.set(Thread.currentThread());//设置为当前线程
        this.countDownLatch.countDown(); //线程减去1
    }
}
